package base_grammar

import "fmt"

func Function_dg() {
	// Function_dgf1()
	Function_dgf2()
	fmt.Printf("f3(5): %v\n", Function_dgf3(5))
	fmt.Printf("f4(3): %v\n", Function_dgf4(3))
}

func Function_dgf4(a int) int {
	if a == 1 || a == 2 {
		return 1
	}
	return Function_dgf4(a-1) + Function_dgf4(a-2)
}

func Function_dgf3(a int) int {
	if a == 1 || a < 0 {
		return 1
	}
	return a * Function_dgf3(a-1)
}

func Function_dgf2() {
	var r int = 1
	for i := 1; i <= 5; i++ {
		r *= i
	}
	fmt.Printf("r: %v\n", r)
}

func Function_dgf1() {
	// 递归必须要有终止条件
	fmt.Println("========")
	Function_dgf1()
}
